package cn.iocoder.yudao.module.pplan.controller.app.producerecord;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pplan.controller.app.producerecord.vo.AppProduceRecordPageReqVO;
import cn.iocoder.yudao.module.pplan.controller.app.producerecord.vo.AppProduceRecordRespVO;
import cn.iocoder.yudao.module.pplan.controller.app.producerecord.vo.AppProduceRecordSaveReqVO;
import cn.iocoder.yudao.module.pplan.service.producerecord.ProduceRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户 APP - 生产计划-生产计划记录")
@RestController
@RequestMapping("/pplan/produce-record")
@Validated
public class AppProduceRecordController {

    @Resource
    private ProduceRecordService produceRecordService;


    @PutMapping("/update")
    @Operation(summary = "更新生产计划-生产计划记录")
    public CommonResult<Boolean> updateProduceRecord(@Valid @RequestBody AppProduceRecordSaveReqVO updateReqVO) {
        produceRecordService.appUpdateProduceRecord(updateReqVO);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得生产计划-生产计划记录")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppProduceRecordRespVO> getProduceRecord(@RequestParam("id") Long id) {
        AppProduceRecordRespVO produceRecord = produceRecordService.appGetProduceRecord(id);
        return success(produceRecord);
    }

    @GetMapping("/page")
    @Operation(summary = "获得生产计划-生产计划记录分页")
    public CommonResult<PageResult<AppProduceRecordRespVO>> getProduceRecordPage(@Valid AppProduceRecordPageReqVO pageReqVO) {
        PageResult<AppProduceRecordRespVO> pageResult = produceRecordService.appGetProduceRecordPage(pageReqVO);
        return success(pageResult);
    }


}